package com.copa.l2283;

import java.util.HashMap;
import java.util.Map;

/**
 * @author copa
 * @createDate 2023-01-11 10:19
 * @function 哈希表法
 */
public class Test1 {

    public boolean digitCount(String num) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < num.length(); i++) {
            int s = num.charAt(i) - '0';
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        for (int i = 0; i < num.length(); i++) {
            int count = num.charAt(i) - '0';
            if (count != map.getOrDefault(i, 0)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        String num = "1210";
        System.out.println(new Test1().digitCount(num));
    }
}
